package cn.net.cfss.fgbp.face.console.controller;

import cn.net.cfss.fgbp.api.console.dto.IntentionDto;
import cn.net.cfss.fgbp.api.console.inte.IIntentionService;
import cn.net.cfss.fgbp.api.console.vo.IntentionVo;
import cn.net.cfss.fgbp.face.console.util.ReturnUtil;
import cn.net.cfss.fgbp.face.console.vo.BaseParas;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
public class IntentionSceneController {

    @Autowired
    IIntentionService iIntentionService;
    @RequestMapping(value = "/queryIntention",method = RequestMethod.POST)
    public String queryIntention(@RequestBody BaseParas paras){

        String intentionName = paras.getPlain().getString("intentionName");
        String rIntentionId =  paras.getPlain().getString("rIntentionId");

        IntentionVo vo = new IntentionVo();
        vo.setIntentionName(intentionName);
        vo.setrIntentionId(rIntentionId);

        try{
            List<IntentionDto> list = iIntentionService.queryIntention(vo);
            if(list == null){
                return ReturnUtil.returnSucc();
            }else{
                return ReturnUtil.returnSucc(list);
            }
        }catch (Exception e){
            return ReturnUtil.returnErr(e.getMessage());
        }

    }
}
